//
// Created by zken on 2024/12/2.
//

#include "FourthTuple.h"


FourthTuple::FourthTuple() {}

FourthTuple::FourthTuple(const string &op, const string &arg1, const string &arg2, const string &tag) : op(op),
                                                                                                        arg1(arg1),
                                                                                                        arg2(arg2),
                                                                                                        tag(tag) {}

const string &FourthTuple::getArg2() const {
    return arg2;
}

void FourthTuple::setArg2(const string &arg2) {
    FourthTuple::arg2 = arg2;
}

const string &FourthTuple::getOp() const {
    return op;
}

void FourthTuple::setOp(const string &op) {
    FourthTuple::op = op;
}

const string &FourthTuple::getArg1() const {
    return arg1;
}

void FourthTuple::setArg1(const string &arg1) {
    FourthTuple::arg1 = arg1;
}

const string &FourthTuple::getTag() const {
    return tag;
}

void FourthTuple::setTag(const string &tag) {
    FourthTuple::tag = tag;
}

void FourthTuple::setLineId(const string &lineId) {
    FourthTuple::lineId = lineId;
}

const string &FourthTuple::getLineId() const {
    return lineId;
}

void FourthTupleList::gen(const FourthTuple &t) {
}

FourthTuple FourthTupleList::gen(const string &op, const string &arg1, const string &arg2, const string &tag) {
    int id = tempCnt;
    tempCnt += 1;
    // 初始化四元组
    FourthTuple tuple(op, arg1, arg2, "_");
    if (!tag.empty()) {
        tuple.setTag(tag);
    }
    // 加入line
    tuple.setLineId(to_string(list.size()));
    if (tag == newTemp) {
        string t = "T" + to_string(id);
        // 建立四元组
        tuple.setTag(t);
        list.push_back(tuple);
        return tuple;
    } else if (op != "-1") {
        list.push_back(tuple);
        return tuple;
    }
    return tuple;
}

void FourthTupleList::setList(const vector<FourthTuple> &list) {
    FourthTupleList::list = list;
}

const vector<FourthTuple> &FourthTupleList::getList() const {
    return list;
}

string FourthTupleList::getNextLineId() {
    return to_string(list.size());
}
